﻿using System;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using System.IO;

namespace TheOliver.DigitalSignage.Common
{
    public class ImageConverter : IValueConverter
    {

        public ImageConverter()
        {
        }

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return null;
            }
            byte[] bytes = (byte[])value;
            MemoryStream stream = new MemoryStream(bytes);  
            BitmapImage b = new BitmapImage();  
            b.SetSource(stream);
            return b;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
